home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Telnet / NCSA / tn3270 2.3d26 source / tn3270 / settings.c < prev    next >
Text File  |  1991-04-22  |  19KB  |  694 lines

  1. /*
  2.  *  tn3270 for the Macintosh Source Code
  3.  *  Brown University Computing and Information Services
  4.  *  Version 2.3d21, January 17, 1991
  5.  *  Copyright (c) 1988, 1989, 1990, 1991 by Brown University and by
  6.  *  Peter John DiCamillo.
  7.  *
  8.  *  Permission is granted to any individual or institution to use, copy,
  9.  *  or redistribute the binary version of this software and its
  10.  *  documentation provided this notice and the copyright notices are
  11.  *  retained.  Permission is granted to any individual or non-profit
  12.  *  institution to use, copy, modify, or redistribute the source files
  13.  *  of this software provided this notice and the copyright notices are
  14.  *  retained.  This software may not be distributed for profit, either
  15.  *  in original form or in derivative works, nor can the source be
  16.  *  distributed to other than an individual or a non-profit institution.
  17.  *  Any  individual or group interested in seeing and/or using these
  18.  *  source files but who are prevented from doing so by the above
  19.  *  constraints should contact Don Wolfe, Assistant Vice-President for
  20.  *  Computer Systems at Brown University, (401) 863-7250, for possible
  21.  *  software licensing of the source developed at Brown.
  22.  *
  23.  *  Brown University and Peter John DiCamillo make no representations
  24.  *  about the suitability of this software for any purpose.
  25.  *
  26.  *  BROWN UNIVERSITY AND PETER JOHN DICAMILLO GIVE NO WARRANTY, EITHER
  27.  *  EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
  28.  *  INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
  29.  *  WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
  30.  *
  31.  */
  32.  
  33. #define __SEG__ 3270seg3
  34. #include "maclib.h"
  35. #include "termdef.h"
  36. #include "globals.h"
  37.  
  38. #define eofErr    -39
  39. #include    <ctype.h>
  40.  
  41. extern struct Point sfppoint, sfgpoint;
  42. extern PaletteHandle myPalette;
  43.  
  44. OSErr fsrdopen();
  45.  
  46. init_settings()
  47. {
  48. short appmsg, appcount;
  49. AppFile appinfo;
  50. static char * ScrDmpEnb = (char *)0x2f8;
  51. char changed;
  52. OSErr read_settings();
  53.  
  54. /* adjust screen size default to match current display */
  55. adjfmt(&changed, &(cs.windmax), &(cs.dfltptsize), &(cs.altptsize),
  56.        &(cs.altrows), &(cs.altcols));
  57.  
  58. /* initial file settings are defaults */
  59. movmem(cshostname, fshostname, 128);
  60. movmem(cskybdname, fskybdname, 256);
  61. movmem(csnlname, fsnlname, 256);
  62. strcpy(cssndname, dfltsoundname);
  63. movmem(cssndname, fssndname, 256);
  64. fs = cs;
  65.  
  66. /* define variable computed from settings */
  67. serflg = (cs.setsflg == 1);
  68. tcpflg = (cs.setsflg == 2);
  69. if (tcpflg) strcpy(wtitle, "tn3270");
  70. else strcpy(wtitle, "Mac3270");
  71. if (cs.digitpfk) (*ScrDmpEnb) = 0;
  72.          else (*ScrDmpEnb) = ScrDmpSav;
  73. fixbracket = cs.std_brack && (!aplmode) && (stdfont != ALAFONT);
  74.  
  75. /* attempt to get a file id for reading new settings */
  76.  
  77. /* first try file passed by the Finder (or whomever) */
  78. CountAppFiles(&appmsg, &appcount);
  79. if ((appmsg == appOpen) && (appcount > 0)) {
  80.     GetAppFiles(1, &appinfo);
  81.     ptoc(&appinfo.fName);
  82.     if (appinfo.fType == 'GFTS')
  83.         if (0 == get_settings(&appinfo.fName, appinfo.vRefNum, 1)) return(0);
  84.     }
  85.  
  86. /* Next, try a standard get file dialog */
  87. if (0 == read_settings(1)) return(0);
  88. return(1);
  89. }
  90.  
  91. OSErr read_settings(initflg)
  92. char initflg;
  93. {
  94. Point where;
  95. ProcPtr fileFilter, dlgHook;
  96. short numTypes;
  97. SFTypeList typeList;
  98. SFReply reply;
  99.  
  100. where = sfgpoint;
  101. fileFilter = dlgHook = 0;
  102. numTypes = 1;
  103. typeList[0] = 'GFTS';
  104. dlgHook = 0;
  105. arrowcursor();
  106. SFGetFile(&where, "Obtain settings from:", fileFilter,
  107.             numTypes, typeList, dlgHook, &reply);
  108. if (reply.good == 0) return(8);
  109. ptoc(&reply.fName);
  110. return(get_settings(&reply.fName, reply.vRefNum, initflg));
  111. }
  112.  
  113. get_settings(fname, vnum, initflg)
  114. char * fname;
  115. short vnum;
  116. char initflg;
  117. {
  118. short fnum;
  119. OSErr rc;
  120. long count;
  121. int t[67];
  122. short colors[27];
  123. char buffer[768];
  124. char tstring[256];
  125. char tstring2[256];
  126. char tstring3[256];
  127. char tstring4[256];
  128. short tlen, tnum;
  129. char scan_ok;
  130. short i, j, len;
  131. short tcount;
  132. char tsave, changed;
  133. char * tptr, * tend;
  134. static char * ScrDmpEnb = (char *)0x2f8;
  135. unsigned char **temph, **temph2;
  136. Handle getsndresource();
  137. short rid;
  138. ResType rtype;
  139.  
  140.                     /* set default volume to initial settings location */
  141. if (initflg) SetVol(0L, vnum);    
  142. rc = fsrdopen(fname, vnum, &fnum);
  143. if (rc != 0) {
  144.     stoperr(rsetalrt);
  145.     return(rc);
  146.     }
  147.  
  148. count = 766;
  149. rc = FSRead(fnum, &count, buffer);
  150. FSClose(fnum);
  151. if ((rc != 0) && (rc != eofErr)) {
  152.     stoperr(rsetalrt);
  153.     return(rc);
  154.     }
  155. buffer[count] = 0;    /* terminate C string */
  156. tptr = buffer;        /* initialize token pointer */
  157. tcount = 0;            /* initialize token count */
  158. while (1) {
  159.     while (isspace(*tptr)) tptr++;
  160.     if ((*tptr) == 0) break;
  161.     tend = tptr;
  162.     while ((!isspace(*tend)) && ((*tend) != 0)) tend++;
  163.     tsave = (*tend);
  164.     (*tend) = 0;
  165.     if (tcount < 7) rc = sscanf(tptr, "%x", t+tcount);
  166.     else if (tcount == 7) rc = sscanf(tptr, "%d", t+tcount);
  167.     else if (tcount == 8) rc = sscanf(tptr, "%s", tstring);
  168.     else if (tcount < 18) rc = sscanf(tptr, "%d", t+tcount-1);
  169.     else if (tcount < 45) rc = sscanf(tptr, "%x", t+tcount-1);
  170.     else if (tcount < 47) rc = sscanf(tptr, "%d", t+tcount-1);
  171.     else if (tcount < 57) rc = sscanf(tptr, "%x", t+tcount-1);
  172.     else if (tcount == 57) rc = sscanf(tptr, "%s", tstring2);
  173.     else if (tcount < 59) rc = sscanf(tptr, "%x", t+tcount-2);
  174.     else if (tcount == 59) rc = sscanf(tptr, "%s", tstring3);
  175.     else if (tcount < 64) rc = sscanf(tptr, "%d", t+tcount-3);
  176.     else if (tcount == 64) rc = sscanf(tptr, "%s", tstring4);
  177.     else if (tcount < 71) rc = sscanf(tptr, "%x", t+tcount-4);
  178.     if (rc != 1) break;
  179.     tcount++;
  180.     if (tcount == 71) break;
  181.     (*tend) = tsave;
  182.     tptr = tend;
  183.     }
  184.                         /* check validity of data */
  185. scan_ok = 0;
  186. if ((tcount == 16) || (tcount >= 45)) {
  187.     scan_ok = 1;
  188.                                         /* host name */
  189.     tlen = strlen(tstring);
  190.     if ((tlen > 127) || (tlen == 0)) scan_ok = 0;
  191.     if (strcmp(tstring, "''") == 0) tstring[0] = '\0';
  192.                                         /* t array */
  193.                         /* tnum = number of array elements used */
  194.     tnum = tcount;
  195.                         /* adjust for string settings */
  196.     if (tcount > 8) tnum--;
  197.     if (tcount > 57) tnum--;
  198.     if (tcount > 59) tnum--;
  199.     if (tcount > 64) tnum--;
  200.     for (i = 7; i < tnum; i++) {
  201.         if ((i >= 17) && (i <= 43)) continue;    /* skip colors */
  202.         if ((i >= 50) && (i <= 52)) continue;    /* status line color */
  203.         switch(i) {
  204.             case 8:                        /* connection type */
  205.             case 47:                    /* status line time */
  206.                         if ((t[i] < 0) || (t[i] > 2)) scan_ok = 0;
  207.                         break;
  208.             case 14:                    /* double-click */
  209.                         if ((t[i] < 1) || (t[i] > 36)) scan_ok = 0;
  210.                         break;
  211.             case 44:                    /* alternate rows */
  212.             case 59:                    /* custom rows */
  213.                         if (t[i] < 24) scan_ok = 0;
  214.                         break;
  215.             case 58:                    /* alternate columns */
  216.             case 60:                    /* custom columns */
  217.                         if (t[i] < 80) scan_ok = 0;
  218.                         break;
  219.             case 45:                    /* alternate font size*/
  220.             case 57:                    /* default font size */
  221.                         if ((t[i] != 9) && (t[i] != 12)) scan_ok = 0;
  222.                         break;
  223.             case 7:                        /* debug level */
  224.             case 9:                        /* timeout */
  225.             case 10:                    /* retries */
  226.             case 62:                    /* window h pos */
  227.             case 63:                    /* window v pos */
  228.             case 65:                    /* text creator */
  229.                         break;
  230.             case 61:                    /* savewpos */
  231.                         if ((t[i] < 0) || (t[i] > 2)) scan_ok = 0;
  232.                         break;
  233.             default:                    /* boolean flags */
  234.                         if ((t[i] != 0) && (t[i] != 1)) scan_ok = 0;
  235.                          break;
  236.             }
  237.         }
  238.     if (tcount >= 58) {
  239.         tlen = strlen(tstring2);                /* keymap name */
  240.         if ((tlen > 255) || (tlen == 0)) scan_ok = 0;
  241.         }
  242.     if (tcount >= 60) {
  243.         tlen = strlen(tstring3);                /* national language */
  244.         if ((tlen > 255) || (tlen == 0)) scan_ok = 0;
  245.         }
  246.     if (tcount >= 65) {
  247.         tlen = strlen(tstring4);                /* 'snd ' name */
  248.         if ((tlen > 255) || (tlen == 0)) scan_ok = 0;
  249.         }
  250.                             /*  check window position present if saved */
  251.     if (tcount >= 66) {
  252.         if ((t[61] == 2) && (tcount < 68)) scan_ok = 0;
  253.         }
  254.     }
  255. if (scan_ok == 0) {
  256.     stoperr(ssetalrt);
  257.     return(12);
  258.     }
  259.  
  260. /* save name of good file */
  261. movmem(fname, s_fName, 64);
  262.  
  263. for (i=0; i < 7; i++) fs.attrmap[i] = cs.attrmap[i] = t[i];
  264. fs.dblevel = cs.dblevel = t[7];
  265. if (initflg) {
  266.     fs.setsflg = cs.setsflg = t[8];        /* ignored if not initialization */
  267.     serflg = (cs.setsflg == 1);            /* connection type can only be  */
  268.     tcpflg = (cs.setsflg == 2);            /* changed using the dialog */
  269.     }
  270. if (!tcpflg) for (i=0; i < tlen; i++) tstring[i] = toupper(tstring[i]);
  271. strcpy(fshostname, tstring);
  272. strcpy(cshostname, tstring);
  273. fs.timeout = cs.timeout = t[9];
  274. fs.retries = cs.retries = t[10];
  275. fs.insreset = cs.insreset = t[11];
  276. fs.impnull = cs.impnull = t[12];
  277. fs.digitpfk = cs.digitpfk = t[13];
  278. if (cs.digitpfk) (*ScrDmpEnb) = 0;
  279.          else (*ScrDmpEnb) = ScrDmpSav;
  280. fs.mousepf = cs.mousepf = t[14];
  281. if (tcount >= 45) {
  282.     fs.basecolor = cs.basecolor = t[15];
  283.     fs.exactcolor = cs.exactcolor = t[16];
  284.     for (i=0; i < 27; i++) colors[i] = t[i+17];
  285.     movmem(colors, &fs.usrwhite, 54);
  286.     cs.usrwhite = fs.usrwhite;
  287.     cs.usryellow = fs.usryellow;
  288.     cs.usrpink = fs.usrpink;
  289.     cs.usrturquoise = fs.usrturquoise;
  290.     cs.usrgreen = fs.usrgreen;
  291.     cs.usrred = fs.usrred;
  292.     cs.usrblue = fs.usrblue;
  293.     cs.usrblack = fs.usrblack;
  294.     cs.usrback = fs.usrback;
  295.     if (tcount >= 54) {
  296.         cs.usrstat.red = fs.usrstat.red = t[50];
  297.         cs.usrstat.green = fs.usrstat.green = t[51];
  298.         cs.usrstat.blue = fs.usrstat.blue = t[52];
  299.         }
  300.     if (colormac && (myWindow != 0)) {
  301.         fixcolors(myPalette);
  302.         ActivatePalette(myWindow);
  303.         updCTab();
  304.         newbackcolor();
  305.         }
  306.     }
  307. /* handle window position settings */
  308. if (tcount >= 66) {
  309.     cs.savewpos = fs.savewpos = (t[61] > 0);
  310.     if (t[61] == 2) {
  311.         cs.windpth = fs.windpth = t[62];
  312.         cs.windptv = fs.windptv = t[63];
  313.         wposok = 1;
  314.         }
  315.     }
  316. /* handle auto-connect setting */
  317. if (tcount >= 69) {
  318.     cs.autoconn = fs.autoconn = t[64];
  319.     }
  320. /* handle text creator setting */
  321. if (tcount >= 70) {
  322.     cs.text_creator = fs.text_creator = t[65];
  323.     }
  324. /* handle PS simulation setting */
  325. if (tcount >= 71) {
  326.     cs.simps = fs.simps = t[66];
  327.     }
  328. /* handle screen format settings */
  329. if (tcount >= 61) {                        /* new format */
  330.     fs.altrows = cs.altrows = t[44];
  331.     fs.altptsize = cs.altptsize = t[45];
  332.     fs.windmax = cs.windmax = t[55];
  333.     fs.dfltptsize = cs.dfltptsize = t[57];
  334.     if (tcount >= 62) fs.altcols = cs.altcols = t[58];
  335.     if (tcount >= 63) fs.custrows = cs.custrows = t[59];
  336.     if (tcount >= 64) fs.custcols = cs.custcols = t[60];
  337.     }
  338. else {                                    /* old format */
  339.     if (tcount >= 46) fs.altrows = cs.altrows = t[44];
  340.     if (tcount >= 47) 
  341.         fs.altptsize = cs.altptsize = fs.dfltptsize = cs.dfltptsize = t[45];
  342.     if (tcount >= 57) fs.windmax = cs.windmax = t[55];
  343.     fs.altcols = cs.altcols = 80;
  344.     }
  345. adjfmt(&changed, &cs.windmax, &cs.dfltptsize, &cs.altptsize,
  346.        &cs.altrows, &cs.altcols);
  347. if (changed) {
  348.     note_err(fmtalrt);
  349.     }
  350. newwindfmt();    /* make changes now if possible */
  351.  
  352. if (tcount >= 58) copyrdstr(fskybdname, tstring2);
  353. if (tcount >= 60) copyrdstr(fsnlname, tstring3);
  354. if (tcount >= 65) copyrdstr(fssndname, tstring4);
  355. if (tcount >= 48) fs.invertbw = cs.invertbw = t[46];
  356. if (tcount >= 49) fs.stat_time = cs.stat_time = t[47];
  357. if (tcount >= 50) fs.curpos = cs.curpos = t[48];
  358. if (tcount >= 51) {
  359.     fs.blockcurs = cs.blockcurs = t[49];
  360.     if (myWindow != 0) newcur();
  361.     }
  362. if (tcount >= 55) fs.ext3270 = cs.ext3270 = t[53];
  363. if (tcount >= 56) {
  364.     fs.std_brack = cs.std_brack = t[54];
  365.     fixbracket = cs.std_brack && (!aplmode) && (stdfont != ALAFONT);
  366.     }
  367. if (tcount >= 58) {
  368.     temph = GetNamedResource('GFKB', fskybdname);
  369.     if (temph == 0L) {
  370.         stoperr(kbsetalrt);
  371.         }
  372.     else {
  373.         kb_handle = temph;
  374.         GetResInfo(kb_handle, &rid, &rtype, tstring2);
  375.         strcpy(fskybdname, tstring2);
  376.         strcpy(cskybdname, tstring2);
  377.         }
  378.     }
  379. if (tcount >= 59) fs.repnull = cs.repnull = t[56];
  380. if (tcount >= 60) {
  381.     /* check for default */
  382.     GetItem(nlMenu, 1, tstring3);
  383.     if (strcmp(tstring3, fsnlname) == 0) {
  384.         strcpy(csnlname, tstring3);
  385.         nl_handle = 0;
  386.         newstdfont(NORMALFONT);
  387.         plainala = 0;
  388.         }
  389.     /* check resource */
  390.     else {
  391.         temph = GetNamedResource('GFNL', fsnlname);
  392.         if (temph == 0L) {
  393.             stoperr(nlsetalrt);
  394.             }
  395.         else {
  396.             GetResInfo(temph, &rid, &rtype, tstring3);
  397.             strcpy(fsnlname, tstring3);
  398.             strcpy(csnlname, tstring3);
  399.             if (GetHandleSize(temph) == 1) {
  400.                 nl_handle = 0;
  401.                 newstdfont(**temph);
  402.                 plainala = 0;
  403.                 }
  404.             else if (GetHandleSize(temph) == 3) {
  405.                 nl_handle = 0;
  406.                 newstdfont(**temph);
  407.                 plainala = ((*temph)[1] & 0x80) == 0x80;
  408.                           }
  409.             else {
  410.                 nl_handle = temph;
  411.                 defxtab(nl_handle, nltab);
  412.                 newstdfont(NORMALFONT);
  413.                 plainala = 0;
  414.                 }
  415.             }
  416.         }
  417.     }
  418.                         /* get non-purgeable copy of our sound resource */
  419. if ((tcount >= 65) && newroms) {
  420.     if (strcmp(fssndname, dfltsoundname) == 0) {
  421.         if (sndactive) {
  422.             SndDisposeChannel(scp, true);
  423.             sndactive = 0;
  424.             }
  425.         if (sndhandle != 0) DisposHandle(sndhandle);
  426.         sndhandle = 0;
  427.         strcpy(cssndname, fssndname);
  428.         }
  429.     else {
  430.         temph = temph2 = getsndresource(fssndname);
  431.         if (temph == 0L) {
  432.             stoperr(sdsetalrt);
  433.             }
  434.         else {
  435.             rc = HandToHand(&temph2);
  436.             if (rc != noErr) {
  437.                 ReleaseResource(temph);
  438.                 stoperr(sdmemalrt);
  439.                 }
  440.             else {
  441.                 getsndinfo(temph, &rid, &rtype, tstring4);
  442.                 ReleaseResource(temph);
  443.                 if (sndactive) {
  444.                     SndDisposeChannel(scp, true);
  445.                     sndactive = 0;
  446.                     }
  447.                 if (sndhandle != 0) DisposHandle(sndhandle);
  448.                 sndhandle = temph2;
  449.                 strcpy(fssndname, tstring4);
  450.                 strcpy(cssndname, tstring4);
  451.                 }
  452.             }
  453.         }
  454.     }
  455. strcpy(wtitle, fname);
  456. if (myWindow == 0) return(0);
  457. justGrowIcon(0);
  458. invldscr();
  459. cs.stat_time += 8;        /* force time to be re-drawn */
  460. newstat();
  461. newinvbw();
  462. SetWTitle(myWindow, wtitle);
  463. return(0);
  464. }
  465.  
  466. copyrdstr(dest, source) 
  467. unsigned char *dest, *source;
  468. {            
  469.             /* copy string, converting underscores to blanks */
  470. register short i, j, len;
  471. register char usflag;
  472.  
  473. len = strlen(source);
  474. j = 0;
  475. usflag = 0;
  476. for (i=0; i < len; i++) {
  477.     if (source[i] == '_') {
  478.         if (usflag) {
  479.             dest[j++] = '_';
  480.             usflag = 0;
  481.             }
  482.         else {
  483.             usflag = 1;
  484.             }
  485.         }
  486.     else {
  487.         if (usflag) {
  488.             dest[j++] = ' ';
  489.             usflag = 0;
  490.             if (j == 255) break;
  491.             dest[j++] = source[i];
  492.             }
  493.         else {
  494.             dest[j++] = source[i];
  495.             }
  496.         }
  497.     if (j == 255) break;
  498.     }
  499. if (usflag && (j < 255)) {
  500.     dest[j++] = ' ';
  501.     }
  502. dest[j] = 0;
  503. }
  504.  
  505. write_settings()
  506. {
  507. Point where;
  508. ProcPtr dlgHook;
  509. SFReply reply;
  510. OSErr rc;
  511. short fnum, i;
  512. char s[640];
  513. char tstring[128];
  514. char tstring2[256];
  515. char tstring3[256];
  516. char tstring4[256];
  517. long count;
  518. char nullstr;
  519. short savewpos;
  520.  
  521. where = sfppoint;
  522. dlgHook = 0;
  523. /* ctop(s_fName); */
  524. arrowcursor();
  525. SFPutFile(&where, "Save settings as:",
  526.           s_fName, dlgHook, &reply);
  527. /* ptoc(s_fName); */
  528. if (reply.good == 0) return;
  529. ptoc(&reply.fName);
  530. movmem(&reply.fName, s_fName, 64);        /* save filename */
  531. rc = FSDelete(&reply.fName, reply.vRefNum);    /* delete existing file */
  532. if ((rc != 0) && (rc != -43)) {        /* file not found is ok */
  533.     stoperr(wsetalrt);
  534.     return;
  535.     }
  536. rc = Create(&reply.fName, reply.vRefNum, 'GFTM', 'GFTS');
  537. if (rc != 0) {
  538.     stoperr(wsetalrt);
  539.     return;
  540.     }
  541. rc = FSOpen(&reply.fName, reply.vRefNum, &fnum);
  542. if (rc != 0) {
  543.     stoperr(wsetalrt);
  544.     return;
  545.     }
  546.                         /* update window position settings */
  547. updwindpos();
  548. savewpos = cs.savewpos;
  549. if (savewpos && wposok) savewpos = 2;
  550.  
  551.                         /* save current values as file values */
  552. movmem(cshostname, fshostname, 128);
  553. movmem(cskybdname, fskybdname, 256);
  554. movmem(csnlname, fsnlname, 256);
  555. movmem(cssndname, fssndname, 256);
  556. fs = cs;
  557.  
  558. movmem(cshostname, tstring, 128);
  559. nullstr = 1;
  560. for (i=0; i < 128; i++) {
  561.     if (tstring[i] == '\0') break;
  562.     if (tstring[i] == ' ') continue;
  563.     nullstr = 0;
  564.     break;
  565.     }
  566. if (nullstr) strcpy(tstring, "''");
  567.  
  568. copywrstr(tstring2, cskybdname);
  569. copywrstr(tstring3, csnlname);
  570. copywrstr(tstring4, cssndname);
  571.     
  572. sprintf(s, "%x %x %x %x %x %x %x %d %s %d %d %d %d %d %d %d %d %d %x %x %x %x %x %x %x %x",
  573.         cs.attrmap[0], cs.attrmap[1], cs.attrmap[2], cs.attrmap[3],
  574.         cs.attrmap[4], cs.attrmap[5], cs.attrmap[6], cs.dblevel, tstring,
  575.         cs.setsflg, cs.timeout, cs.retries, cs.insreset, cs.impnull, cs.digitpfk,
  576.         cs.mousepf, cs.basecolor, cs.exactcolor, cs.usrwhite.red, cs.usrwhite.green,
  577.         cs.usrwhite.blue, cs.usryellow.red, cs.usryellow.green, cs.usryellow.blue,
  578.         cs.usrpink.red, cs.usrpink.green); 
  579. count = strlen(s);
  580. rc = FSWrite(fnum, &count, s);
  581. if (rc != 0) {
  582.     stoperr(wsetalrt);
  583.     return;
  584.     }
  585. sprintf(s, " %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %d %d %x %x %x %x",
  586.         cs.usrpink.blue, cs.usrturquoise.red,
  587.         cs.usrturquoise.green, cs.usrturquoise.blue, cs.usrgreen.red, cs.usrgreen.green,
  588.         cs.usrgreen.blue, cs.usrred.red, cs.usrred.green, cs.usrred.blue, cs.usrblue.red,
  589.         cs.usrblue.green, cs.usrblue.blue, cs.usrblack.red, cs.usrblack.green,
  590.         cs.usrblack.blue, cs.usrback.red, cs.usrback.green, cs.usrback.blue,
  591.         cs.altrows, cs.altptsize, cs.invertbw, cs.stat_time, cs.curpos, cs.blockcurs);
  592. count = strlen(s);
  593. rc = FSWrite(fnum, &count, s);
  594. if (rc != 0) {
  595.     stoperr(wsetalrt);
  596.     return;
  597.     }
  598. sprintf(s, " %x %x %x %x %x %x %s %x %s %d %d %d %d %s %x %x %x %x %x %x",
  599.         cs.usrstat.red, cs.usrstat.green, cs.usrstat.blue, cs.ext3270,
  600.         cs.std_brack, cs.windmax, tstring2, cs.repnull, tstring3,
  601.         cs.dfltptsize, cs.altcols, cs.custrows, cs.custcols, tstring4,
  602.         savewpos, cs.windpth, cs.windptv, cs.autoconn, cs.text_creator,
  603.         cs.simps);
  604. count = strlen(s);
  605. rc = FSWrite(fnum, &count, s);
  606. if (rc != 0) {
  607.     stoperr(wsetalrt);
  608.     return;
  609.     }
  610. rc = FSClose(fnum);
  611. if (rc != 0) stoperr(wsetalrt);
  612. }
  613.  
  614. copywrstr(dest, source)
  615. char *dest, *source;
  616. {
  617. register short i, j, len;
  618. register unsigned char c;
  619.  
  620. len = strlen(source);    /* copy name, converting blanks and underscores */
  621. j = 0;
  622. for (i=0; i < len; i++) {
  623.     c = source[i];
  624.     if (c == '_') {
  625.         dest[j++] = '_';
  626.         if (j == 255) break;
  627.         dest[j++] = '_';
  628.         }
  629.     else if (c == ' ') {
  630.         dest[j++] = '_';
  631.         }
  632.     else {
  633.         dest[j++] = c;
  634.         }
  635.     if (j == 255) break;
  636.     }
  637. dest[j] = 0;
  638. }
  639.  
  640. short new_settings()
  641. {
  642. short savepth, saveptv, rc;
  643.  
  644. if (strcmp(cshostname, fshostname) != 0) return(1);
  645. if (strcmp(cskybdname, fskybdname) != 0) return(1);
  646. if (strcmp(csnlname, fsnlname) != 0) return(1);
  647. if (strcmp(cssndname, fssndname) != 0) return(1);
  648.                         /* compare all other settings, except window position */
  649. savepth = fs.windpth;
  650. saveptv = fs.windptv;
  651. fs.windpth = cs.windpth;
  652. fs.windptv = cs.windptv;
  653. rc = (fs != cs);
  654. fs.windpth = savepth;
  655. fs.windptv = saveptv;
  656. return(rc);
  657. }
  658.  
  659. OSErr fsrdopen(fname, vref, fref)    /* open file read-only */
  660. char * fname;
  661. short vref;
  662. short * fref;
  663. {
  664. IOParam pbi;
  665. OSErr rc;
  666.  
  667. /* initialize parameter block */
  668. setmem(&pbi, sizeof(IOParam), 0);
  669.  
  670. pbi.ioNamePtr = (StringPtr)fname;
  671. pbi.ioVRefNum = vref;
  672. pbi.ioPermssn = fsRdPerm;
  673. ctop(fname);
  674. rc = PBOpen(&pbi, 0);
  675. *fref = pbi.ioRefNum;
  676. ptoc(fname);
  677. return(rc);
  678. }
  679.  
  680. newwindfmt()            /* make new screen format changes if possible */
  681. {
  682. if (myWindow == 0) return;
  683.  
  684. if ((cs.altrows == ses_altrows) && (cs.altcols == ses_altcols)) {
  685.     ses_altptsize = cs.altptsize;
  686.     ses_dfltptsize = cs.dfltptsize;
  687.     ses_windmax = cs.windmax;
  688.     newmode(cur_mode, 0);
  689. }
  690. else {
  691.     note_err(windfmtalrt);
  692.     }
  693. }
  694.